package com.moleq.base;

import com.moleq.models.GlobalInfo;

import android.app.AlertDialog;
import android.content.Context;

public class MoleQBaseDialog extends AlertDialog implements OnResultListener {

	public static final int DIALOG_CLOSE = -1;
	public static final int DIALOG_INPUT_CHECK_INFO = 0;
	public static final int DIALOG_INPUT_GIFT_CARD_INFO = 1;
	

	protected GlobalInfo globalSetting = GlobalInfo.getInstance();
	protected Context mContext;
	private Object mListener;

	public MoleQBaseDialog(Context context, int theme, Object listener) {
		super(context, theme);
		constructor(context, listener);
	}

	public MoleQBaseDialog(Context context, Object listener) {
		super(context);
		constructor(context, listener);
	}

	private void constructor(Context context, Object listener) {
		mListener = listener;
		mContext = context;
		this.getWindow().setWindowAnimations(android.R.style.Animation);
	}

	@Override
	public void onCloseWithReturn(Class<? extends MoleQBaseDialog> pramClass, int viewId, String returnvalue) {
		// TODO Auto-generated method stub

	}

	public void onCloseWithReturn(int viewId, String parm) {
		if (mListener instanceof OnResultListener) {
			OnResultListener linstener = (OnResultListener) this.mListener;
			linstener.onCloseWithReturn(this.getClass(), viewId, parm);
		}
		dismiss();
	}
	

	public void onResultResponse(int id, Object obj) {
		// TODO Auto-generated method stub

	}

	
	public void onCloseWithReturn(Object obj) {
//		if (mListener instanceof OnResultListener) {
//			OnResultListener linstener = (OnResultListener) this.mListener;
//			linstener.onCloseWithReturn(obj);
//		}
		onReturnValue(0,obj);
		dismiss();
	}

	@Override
	public void onReturnValue(int what, Object obj) {
		if (mListener instanceof OnResultListener) {
			OnResultListener linstener = (OnResultListener) this.mListener;
			linstener.onReturnValue(what, obj);
		}
	}

	@Override
	public void onShowingMessageDlg(boolean isShowing) {
		// TODO Auto-generated method stub

	}

}
